
layui.use(['form', 'admin', 'ax'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;

    var pid = system.getUrlParam("id");
    //赋值类对象
    $("#pid").val(pid ? pid : 0);

    // 表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(system.contextPath + "/develop/functionRole/add", function (res) {
            if(res.status){
                system.success("添加成功！");
                //传给上个页面，刷新table用
                admin.putTempData('formOk', true);
                //关掉对话框
                admin.closeThisDialog();
            }else{
                system.error("添加失败！" + res.msg);
            }
        }, function (res) {
            system.error("添加失败！" + res.msg);
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });
});